home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / ohlfind.zip / DEFS.H < prev    next >
C/C++ Source or Header  |  1990-07-02  |  4KB  |  163 lines

  1. /* Common definitions for the 'find' package
  2.    Copyright (C) 1987, 1990 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 1, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. #include "regex.h"
  19.  
  20. typedef char boolean;
  21. #define        true    1
  22. #define        false    0
  23.  
  24. /* Pointer to function returning boolean. */
  25. typedef boolean (*PFB)();
  26.  
  27. char *malloc ();
  28. int fprintf ();
  29. int printf ();
  30. long time ();
  31. void exit ();
  32. void free ();
  33.  
  34. PFB find_parser ();
  35. boolean no_side_effects ();
  36. boolean parse_print ();
  37. char *xmalloc ();
  38. struct pred_struct *get_expr ();
  39. struct pred_struct *get_new_pred ();
  40. struct pred_struct *get_new_pred_chk_op ();
  41. struct pred_struct *insert_victim ();
  42. void error ();
  43. void usage ();
  44. void process_path ();
  45.  
  46. #ifdef    DEBUG
  47. void print_tree ();
  48. void print_list ();
  49. #endif    /* DEBUG */
  50.  
  51. /* Argument structures for predicates. */
  52.  
  53. enum comparison_type
  54. {
  55.   COMP_GT,
  56.   COMP_LT,
  57.   COMP_EQ
  58. };
  59.  
  60. enum predicate_type
  61. {
  62.   NO_TYPE,
  63.   VICTIM_TYPE,
  64.   UNI_OP,
  65.   BI_OP,
  66.   OPEN_PAREN,
  67.   CLOSE_PAREN
  68. };
  69.  
  70. enum predicate_precedence
  71. {
  72.   NO_PREC,
  73.   OR_PREC,
  74.   AND_PREC,
  75.   NEGATE_PREC,
  76.   MAX_PREC
  77. };
  78.  
  79. struct long_t
  80. {
  81.   enum comparison_type kind;
  82.   unsigned long l_val;
  83. };
  84.  
  85. struct size_t
  86. {
  87.   short kind;
  88.   boolean block;
  89.   unsigned long size;
  90. };
  91.  
  92. struct exec_t
  93. {
  94.   short *path_loc;
  95.   char **vec;
  96. };
  97.  
  98. struct pred_struct
  99. {
  100.   /* Pointer to the function that implements this predicate.  */
  101.   PFB pred_func;
  102. #ifdef    DEBUG
  103.   char *p_name;
  104. #endif
  105.  
  106.   /* The type of this node.  There are two kinds.  The first is real
  107.      predicates ("victims") such as -perm, -print, or -exec.  The
  108.      other kind is operators for combining predicates. */
  109.   enum predicate_type p_type;
  110.  
  111.   /* The precedence of this node.  Only has meaning for operators. */
  112.   enum predicate_precedence p_prec;
  113.  
  114.   /* True if this predicate node produces side effects. */
  115.   boolean side_effects;
  116.  
  117.   /* Information needed by the predicate processor.
  118.      Next to each member are listed the predicates that use it. */
  119.   union
  120.   {
  121.     char *str;            /* name fstype */
  122.     struct re_pattern_buffer *regex; /* regex */
  123.     struct exec_t exec_vec;    /* exec ok */
  124.     struct long_t info;        /* atime ctime mtime inum links */
  125.     struct size_t size;        /* size */
  126.     unsigned short uid;        /* user */
  127.     unsigned short gid;        /* group */
  128.     time_t time;        /* newer */
  129.     unsigned long perm;        /* perm permmask */
  130.     unsigned long type;        /* type */
  131.   } args;
  132.  
  133.   /* The next predicate in the user input sequence,
  134.      which repesents the order in which the user supplied the
  135.      predicates on the command line. */
  136.   struct pred_struct *pred_next;
  137.  
  138.   /* The right and left branches from this node in the expression
  139.      tree, which represents the order in which the nodes should be
  140.      processed. */
  141.   struct pred_struct *pred_left;
  142.   struct pred_struct *pred_right;
  143. };
  144.  
  145. /* The number of seconds in a day. */
  146. #define        DAYSECS        86400
  147.  
  148. /* The number of bytes in a block for -size. */
  149. #define        BLKSIZE        512
  150.  
  151. extern int errno;
  152.  
  153. extern char *program_name;
  154. extern struct pred_struct *predicates;
  155. extern struct pred_struct *last_pred;
  156. extern boolean do_dir_first;
  157. extern unsigned long perm_mask;
  158. extern long cur_day_start;
  159. extern boolean full_days;
  160. extern boolean stay_on_filesystem;
  161. extern boolean stop_at_current_level;
  162. extern int exit_status;
  163.